//
//  String+extension.swift
//  abbWeibo
//
//  Created by 张可 on 16/1/18.
//  Copyright © 2016年 张可. All rights reserved.
//

import UIKit

extension String {
    
    /**
     将当前字符串拼接到cache目录后面
     */
    func cacheDir() ->String {
        
        let path = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true).last! as NSString
        
        return path.stringByAppendingPathComponent((self as NSString).lastPathComponent)
        
    }
    
    /**
     将当前字符串拼接到doc目录后面
     */
    func docDir() ->String {
        
        let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).last! as NSString
        
        return path.stringByAppendingPathComponent((self as NSString).lastPathComponent)
        
    }
    
    /**
     将当前字符串拼接到tmp目录后面
     */
    func tmoDir() ->String {
        
        let path = NSTemporaryDirectory() as NSString
        
        return path.stringByAppendingPathComponent((self as NSString).lastPathComponent)
    }
}
